<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .image{
            width: 300px;
        }
    </style>
</head>

<body>
    <div>
        <img src="" alt="加载失败" class="image">
    </div>

    <script>
        const loadImgAsymc = url =>{
            return new Promise((resolve,reject)=>{
                const img = new Image();
                img.onload=()=>{
                    resolve(img);
                };
                img.onerror = ()=>{
                    reject(new Error(`Could not load Image at ${url}`))
                }
                img.src = url
            })
        }

        let image = document.querySelector('.image')
        loadImgAsymc('./img_112.jpg').then(img=>{
            setTimeout(()=>{
                image.src = img.src
            },2000)
        })
    </script>
</body>

</html>